package edu.yuhf.tts.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import edu.yuhf.dbutil.JdbcTemplate;
import edu.yuhf.tts.cui.SelectCUI;
import edu.yuhf.tts.domain.Order;

public class ReturnDao {
	//将当前用的所有订单信息全部显示
		public List<Order> queryreturn(){
			List<Order> list=new ArrayList<>();
			String sql="select * from tts_orderform where user_id=?";
			list=JdbcTemplate.query(sql, (rs)->{
				List<Order> list0=new ArrayList<>();
				try {
					while(rs.next()) {
					Order order=new Order(rs.getInt(1),rs.getInt(2),rs.getString(3),rs.getDate(4).toLocalDate(),rs.getInt(5),rs.getBigDecimal(6));
					list0.add(order);
					}
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return list0;
			}, SelectCUI.user.getId());
			return list;
		}
		
		//删除表中的number 号 订单
		public int returnd(int number) {
			int rowNum=0;
			String sql="delete from tts_orderform where id=?";
			rowNum=JdbcTemplate.update(sql, number);
			return rowNum;
		}
}
